<?php
/**
 * 用户标签模型 - 数据对象模型
 * @author jason <yangjs17@yeah.net>
 * @version TS3.0
 */
class UserTagModel extends Model {

	protected $tableName = 'user_tag';
    
	/**
	 * 获取用户全部标签数据
	 * 
	 * @author diccn
	 * 2014-9-7
	 */
	public function getUserAllTag($mid){
		return $this->where(array('uid'=>$mid))->findAll();
	}
	/**
	 * 添加标签
	 * 
	 * @author diccn
	 * 2014-9-7
	 */
	public function addTagName($tag_name,$mid){
		$data['uid'] = $mid;
		$data['tag_name'] = $tag_name;
		$data['tag_id'] = model('Tag')->getTagId($tag_name);
		$data['spell'] = model('PinYin')->Pinyin( $tag_name );
		$data['first_letter'] = substr($data['spell'],0,1);
		$data['ctime'] = $data['mtime'] = time();
		return $this->add($data);
	}
}